package cn.zyq.ykb.controller.mgt.config;

import org.springframework.security.access.prepost.PreAuthorize;
import cn.zyq.ykb.system.ry.util.poi.ExcelUtil;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.annotation.Log;
import cn.zyq.ykb.system.ry.enums.BusinessType;
import cn.zyq.ykb.beans.config.ConfigCpa;
import cn.zyq.ykb.service.config.ConfigCpaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.zyq.ykb.system.common.BaseController;
import cn.zyq.ykb.system.common.PageParam;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 配置-网赚Controller
 *
 * @author SystemAuth
 * @date 2024-01-11
 */

@RestController(value = "MgtConfigCpaController")
@RequestMapping("/mgt/configCpa")
@Api(tags = "配置-网赚接口")
public class ConfigCpaController extends BaseController {

    @Autowired
    private ConfigCpaService configCpaService;

    /**
     * 查询配置-网赚列表
     */
    @ApiOperation(value = "列表", response = ConfigCpa.class)
    @PostMapping("/list")
    public Object list(@RequestBody PageParam pageParam) {
        return this.configCpaService.selectConfigCpaList(pageParam);
    }

    /**
     * 获取配置-网赚详细信息
     */
    @ApiOperation(value = "详情", response = ConfigCpa.class)
    @GetMapping(value = "/{configCpaID}")
    public Object getInfo(@PathVariable("configCpaID") Integer configCpaID) {
        return this.configCpaService.selectConfigCpaByConfigCpaID(configCpaID);
    }
    /**
     * 获取配置-网赚详细信息
     */
    @ApiOperation(value = "详情", response = ConfigCpa.class)
    @GetMapping(value = "/detail/{serviceID}")
    public Object getInfo(@PathVariable(value = "serviceID") String serviceID) {
        return this.configCpaService.selectConfigCpaByServiceID(serviceID);
    }

    /**
     * 新增配置-网赚
     */
    @ApiOperation(value = "新增")
    @Log(title = "配置-网赚", businessType = BusinessType.INSERT)
    @PostMapping
    public Object add(@RequestBody ConfigCpa configCpa) {
        return this.configCpaService.insertConfigCpa(configCpa);
    }

    /**
     * 修改配置-网赚
     */
    @ApiOperation(value = "编辑")
    @Log(title = "配置-网赚", businessType = BusinessType.UPDATE)
    @PutMapping
    public Object edit(@RequestBody ConfigCpa configCpa) {
        return this.configCpaService.updateConfigCpa(configCpa);
    }

    /**
     * 删除配置-网赚
     */
    @ApiOperation(value = "删除")
    @Log(title = "配置-网赚", businessType = BusinessType.DELETE)
    @DeleteMapping("/{configCpaIDs}")
    public Object remove(@PathVariable Integer[] configCpaIDs) {
        return this.configCpaService.deleteConfigCpaByConfigCpaIDs(configCpaIDs);
    }
}
